<?PHP require_once('inc/int.php'); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
  <title>DMDirc :: <?PHP echo t('menu_screenshots'); ?></title>
  <link rel="stylesheet" type="text/css" href="res/style.css">
  <link rel="icon" type="image/png" href="res/favicon.png">
 </head>
 <body>
  <div id="container">
   <img id="logo" src="res/logo.png" alt="DMDirc logo">
   <h1>DMDirc</h1>
<?PHP define('PAGE', 'about'); define('SUBPAGE', 'screenshots'); require_once('inc/menu.php'); ?>
   <div id="content">

    <h2><?PHP echo t('menu_screenshots'); ?></h2>

<?PHP
 $files = array();

 if (strpos($_SERVER['REQUEST_URI'], '?file=') !== false) {
  $_GET['file'] = substr($_SERVER['REQUEST_URI'], 6 + strpos($_SERVER['REQUEST_URI'], '?file='));
 }

 foreach (glob('res/screenshots/current/*') as $dir) {
  foreach (glob($dir . '/*') as $subdir) {
   foreach (glob($subdir . '/*') as $file) {
    $files[basename($dir)][basename($subdir)][] = $file;
    if (isset($_GET['file']) && $_GET['file'] == $file) {
     define('FILE', $file);
    }
   } 
  } 
 }

 $files2 = array();
 foreach (glob('res/docs/*') as $file) {
  if (basename($file) != 'sspending.png') {
   $files2['docs']['docs'][] = $file;
   if (isset($_GET['file']) && $_GET['file'] == $file) {
    define('FILE', $file);
    $files =& $files2;
   }
  }
 }

 if (!defined('FILE')) {
  define('FILE', current($files[key($files)][key($files[key($files)])]));
 }

?>
      <div class="screenshot">
        <img alt="<?PHP echo t('index_screenshot'); ?>" id="screenshot" src="<?PHP echo htmlentities(FILE); ?>">
      </div>

      <div style="height: 120px; white-space: nowrap; border: 1px solid #ccc; padding: 10px; overflow: auto; margin-top: 20px;">
<?PHP
 foreach ($files as $os => $data) {
  foreach ($data as $subos => $screens) {
   foreach ($screens as $screen) {
?>
    <a href="?file=<?PHP echo htmlentities($screen); ?>" onClick="document.getElementById('screenshot').src = '<?PHP echo htmlentities($screen); ?>'; return(false);"><img src="res/thumb/<?PHP echo htmlentities(substr($screen, 4)); ?>" alt="<?PHP echo t('index_screenshot'); ?>"></a>
<?PHP    
   }
  }
 }
?>
      </div>

      <p><?PHP echo t('screenshot_historical'); ?></p>

   </div>
   <div id="footer">
   </div>
  </div>
 </body>
</html>
